<template>
  <div class="home-banner">
    <!-- 通过父传子,将数据传过去 -->
    <XtxSlider :sliders="bannerList" :is-auto="true"/>
  </div>
</template>

<script>
import { findBanner } from '@/api/home'
import { ref, onMounted } from 'vue'
export default {
  name: 'HomeBanner',
  setup () {
    // 获取轮播图数据 重新赋值 渲染到页面
    const bannerListRef = ref([])
    async function loadBannerList () {
      const res = await findBanner()
      bannerListRef.value = res.data.result
    }
    onMounted(() => {
      // 调用函数
      loadBannerList()
    })
    return {
      bannerList: bannerListRef
    }
  }
}
</script>

<style scoped lang='less'>
.home-banner {
  width: 1240px;
  height: 500px;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 98;
}
</style>
